//
//  BaseTableViewController.swift
//  LDMicroblog07
//
//  Created by pro on 15/9/16.
//  Copyright © 2015年 pro. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController {
    
    private var userLogin: Bool = false
    
    // 中间视图
    var vistorLoginView: VistorLoginView?
    
    override func loadView() {
        print(userLogin)
        
        userLogin == true ? super.loadView() : setupVistorView()
        
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        //设置左右按钮
        setItems()
    }
    
    //根视图
    private func setupVistorView() {
    
        vistorLoginView = VistorLoginView()
        vistorLoginView!.delegate = self
        view = vistorLoginView
        
    }
    //设置左右按钮
    func setItems() {
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "VistorLoginBtnClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "VistorRegisterBtnClick")
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Table view data source

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 0
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return 0
    }
 

}

extension BaseTableViewController:VistorLoginViewDelegate {

    func VistorLoginBtnClick() {
        
        let OAuthVc = OAuthViewController()
        
        let nav = BaseNavigationController(rootViewController: OAuthVc)
        
        //modal
        presentViewController(nav, animated: true, completion: nil)
        
    }
    func VistorRegisterBtnClick() {
        print(">>>>>")
    }
    
}
